package itheima.com.HashSetTest;

import java.util.HashMap;
import java.util.Map;

public class HashMapDemo02 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();

        map.put("itheima01","小伙");
        map.put("itheima02","小子");
        map.put("itheima03","小海");
        map.put("itheima04","小孩");
        map.put("itheima05","小小");
        map.put("itheima06","小果");

//        method01(map);
//        method02(map);
//        method03(map);
//        method04(map);
        boolean x = map.containsValue("小海");
        System.out.println(x);
    }

    private static void method04(Map<String, String> map) {
        //看是否包含此键
        boolean a = map.containsKey("itheima01");
        boolean b = map.containsKey("1号");
        System.out.println(a);
        System.out.println(b);
    }

    private static void method03(Map<String, String> map) {
        boolean empty1 = map.isEmpty();
        System.out.println(empty1);

        map.clear();
        boolean empty2 = map.isEmpty();
        System.out.println(empty2);
    }

    private static void method02(Map<String, String> map) {
        //根据键可以删除元素
        String s = map.remove("itheima01");
        System.out.println(s);
        System.out.println(map);
    }

    private static void method01(Map<String, String> map) {
        //改变值的对象会进行覆盖，键不能改变
        String put = map.put("itheima01", "小皮");
        System.out.println(map);
    }
}
